package com.rykj.api

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.rykj.api.converter.GsonConverterFactory
import okhttp3.OkHttpClient
import retrofit2.CallAdapter
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory

/**
 * description:
 * <p/>
 * Created by ycw on 2020/04/18.
 */
object RetrofitHelper {

    var retrofit: Retrofit? = null

    fun create(API_URL: String,
        okHttpClient: OkHttpClient = OkHttpHelper.createOkHttp(),
        factory: CallAdapter.Factory = RxJavaCallAdapterFactory.create(),
        converter: Converter.Factory = GsonConverterFactory.create(/*GsonBuilder().create()*/)): Retrofit {
        return Retrofit.Builder().baseUrl(API_URL)
            .addCallAdapterFactory(factory)
            .addConverterFactory(converter)
            .client(okHttpClient)
            .build()
    }

}